<?php 

/**
 * 商品详细模型
 */

class DetailModel extends Model{
    public $table = 'detail';
    
    public $validate = array(
		array('intro','nonull','内容不能为空',2,3),
		array('service','nonull','内容不能为空',2,3)
	);
    
    public function addData($gid){
//  	if(!$this->create()) return FALSE;
    	//处理商品图册
		//如果有传递图片
//		p(Q('post.shopPic'));
		if($pic = Q('post.shopPic')){
			//序列化存入数据库
			//如果读取的时候反序列化读取就可以
			$shopPic = serialize($pic);
			$this->data['shop_pic'] = $shopPic;
			$this->data['goods_gid'] = $gid;
		}
		
//		p($_POST);die;
        $this->add();
    }
	
	public function editData($gid){	
    	//处理商品图册
		//如果有传递图片
//		p($_POST);die;
		if($pic = Q('post.shopPic')){
			//序列化存入数据库
			//如果读取的时候反序列化读取就可以
			$shopPic = serialize($pic);
//			p($shopPic);die;
			$this->data['shop_pic']=$shopPic;
			$this->data['goods_gid']=$gid;
		}
        $this->where("goods_gid={$gid}")->update();
		return true;
    }
	
 }


 ?>